/*
 * @Author: 康某 carl0608@126.com
 * @Date: 2023-04-23 21:51:30
 * @LastEditors: 康某 carl0608@126.com
 * @LastEditTime: 2023-04-23 23:35:24
 * @FilePath: \create-sim\src\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { program } from "commander";
import packageData from "../package.json";
import { createDir, getCmdName } from "./appName.js";
import create from "./create";
import { getPromptValue } from "./prompt";
// const chalk = require("chalk");
// const ora = require("ora");
// 入口函数
const main = async () => {
 //  console.log(chalk.blue("欢迎使用sim-cli！"));
 program.option("-n, --name <value>", "app name");
 program.version(packageData.version, "-v");
 program.parse();
 const options = program.opts();
 // 获取名称
 let name = getCmdName(options, program);
 //检查名称并创建文件夹
 name = await createDir(name);

 // 获取脚手架选项
 const promptValue = await getPromptValue();
 const config = {
  ...promptValue,
  name,
 };
 //  console.log(chalk.yellow("项目正在创建中！"));
 //  const spinner = ora("项目正在创建中！");
 await create(config);
 //  console.log(chalk.green("项目创建完成！"));
 //  spinner.succeed("项目创建完成！");
};

main();
